/**
 * KAYO APPLIANCE CHAINS.
 * Copyright (c) 2016-2016 All Rights Reserved.
 */
package com.leku.mse.dao.impl.member;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.leku.commons.datasource.DataSourceClient;
import com.leku.mse.dao.member.MessageDao;
import com.leku.mse.entity.MessSwitchEntity;
import com.leku.mse.entity.MessageEntity;

/**
 * 功能描述: 消息数据操作
 *
 * @author suiying
 * @created 2017年5月25日
 * @version 1.0.0
 */
@Repository
public class MessageDaoImpl implements MessageDao {

    @Autowired
    private DataSourceClient dataSourceClient;

    /*
     * (non-Javadoc)
     * @see com.leku.memcenter.dao.message.MessageDao#getMessageNum(java.lang.String, java.lang.String,
     * java.lang.String)
     */
    @Override
    public Integer getMessageNum(String memberCode, String messType, String appCode) {
        Map<String, Object> param = new HashMap<String, Object>();

        param.put("memberCode", memberCode);
        param.put("messType", messType);
        param.put("appCode", appCode);

        return dataSourceClient.selectOne("messageDao.getMessageNum", param);
    }

    /*
     * (non-Javadoc)
     * @see com.leku.memcenter.dao.message.MessageDao#insertMessage(com.leku.memcenter.entity.MessageEntity)
     */
    @Override
    public int insertMessage(MessageEntity message) {

        dataSourceClient.update("dbBaseDao.setCharset");

        return dataSourceClient.insert("messageDao.insertMessage", message);
    }

    /*
     * (non-Javadoc)
     * @see com.leku.mse.dao.member.MessageDao#getMessSwitch(java.lang.String)
     */
    @Override
    public MessSwitchEntity getMessSwitch(String memberCode) {
        Map<String, Object> param = new HashMap<String, Object>();

        param.put("memberCode", memberCode);

        return dataSourceClient.selectOne("messageDao.getMessSwitch", param);
    }

}
